//
//  CZFooterView.m
//  A01- 团购
//
//  Created by Rainy Zou on 15/11/23.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "CZFooterView.h"

@interface CZFooterView()
@property (weak, nonatomic) IBOutlet UIButton *loadMoreBtn;

@property (weak, nonatomic) IBOutlet UIView *loadMoreView;

@end

@implementation CZFooterView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (IBAction)loadMoreClick:(id)sender {
    self.loadMoreBtn.hidden = YES;
    self.loadMoreView.hidden = NO;
    
    //延时执行
//    self performSelector:<#(nonnull SEL)#> withObject:<#(nullable id)#> afterDelay:<#(NSTimeInterval)#>
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0*NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
        self.loadMoreBtn.hidden = NO;
        self.loadMoreView.hidden = YES;
        
        //3 向代理对象发送消息
        if([self.delegate respondsToSelector:@selector(footerViewDidClickedLoadMoreBtn:)]){
            [self.delegate footerViewDidClickedLoadMoreBtn:self];
        }
        
    });
}


+ (instancetype)footerView{
    CZFooterView *footView =  [[[NSBundle mainBundle] loadNibNamed:@"CZFooterView" owner:nil options:nil] lastObject];
    
    footView.loadMoreBtn.layer.cornerRadius = 5;
    footView.loadMoreBtn.layer.masksToBounds = YES;
    
    return footView;
}

@end
